package net.lainiao.morethread.Chapter4.demo9;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2017/3/3.
 */
public class ExecutableTask implements Callable<String> {
    private String name;

    public ExecutableTask(String name){
        this.name=name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String call() throws Exception {
        long duration = (long) (Math.random() * 10);
        System.out.println(this.name+" Waiting "+duration+" seconds for results");
        TimeUnit.SECONDS.sleep(duration);
        return "hello,workd,I'am "+this.name;
    }
}
